home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / ole2book.zip / CHAP10.ZIP / CHAP10 / SCHMOO / POLYLINE.H < prev    next >
C/C++ Source or Header  |  1993-06-13  |  5KB  |  162 lines

  1. /*
  2.  * POLYLINE.H
  3.  *
  4.  * Definitions and function prototypes for the PolyLine window class
  5.  * that can be treated like its own control.
  6.  *
  7.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  8.  *
  9.  * Kraig Brockschmidt, Software Design Engineer
  10.  * Microsoft Systems Developer Relations
  11.  *
  12.  * Internet  :  kraigb@microsoft.com
  13.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  14.  */
  15.  
  16.  
  17. #ifndef _POLYLINE_H_
  18. #define _POLYLINE_H_
  19.  
  20. //Versioning.
  21. #define VERSIONMAJOR                2
  22. #define VERSIONMINOR                0
  23. #define VERSIONCURRENT              0x00020000
  24.  
  25. //Classname
  26. #define SZCLASSPOLYLINE             "polyline"
  27.  
  28. #define HIMETRIC_PER_INCH           2540
  29. #define CPOLYLINEPOINTS             20
  30.  
  31. //Window extra bytes and offsets
  32. #define CBPOLYLINEWNDEXTRA          (sizeof(LONG))
  33. #define PLWL_STRUCTURE              0
  34.  
  35.  
  36. //Version 2.0 Polyline Structure
  37. typedef struct __far tagPOLYLINEDATA
  38.     {
  39.     WORD        wVerMaj;                //Major version number.
  40.     WORD        wVerMin;                //Minor version number.
  41.     WORD        cPoints;                //Number of points.
  42.     BOOL        fReserved;              //Previously fDrawEntire, obsoleted
  43.     RECT        rc;                     //Rectangle of this figure (client)
  44.     POINT       rgpt[CPOLYLINEPOINTS];  //Array of points on 0-32767 grid.
  45.  
  46.     //Version 2.0 additions
  47.     COLORREF    rgbBackground;          //Background color
  48.     COLORREF    rgbLine;                //Line color
  49.     int         iLineStyle;             //Line style
  50.     } POLYLINEDATA, FAR *LPPOLYLINEDATA;
  51.  
  52. #define CBPOLYLINEDATA   sizeof(POLYLINEDATA)
  53. #define CBPOLYLINEDATA20 sizeof(POLYLINEDATA)
  54.  
  55.  
  56. //Version 1.0 Polyline Structure
  57. typedef struct __far tagPOLYLINEDATA10
  58.     {
  59.     WORD        wVerMaj;                //Major version number.
  60.     WORD        wVerMin;                //Minor version number.
  61.     WORD        cPoints;                //Number of points.
  62.     BOOL        fDrawEntire;            //Flag to draw entire figure.
  63.     RECT        rc;                     //Rectangle of this figure (parent)
  64.     POINT       rgpt[CPOLYLINEPOINTS];  //Array of points scaled to rc
  65.     } POLYLINEDATA10, FAR *LPPOLYLINEDATA10;
  66.  
  67. #define CBPOLYLINEDATA10 sizeof(POLYLINEDATA10)
  68.  
  69.  
  70. //POLYWIN.CPP
  71. LRESULT __export FAR PASCAL PolylineWndProc(HWND, UINT, WPARAM, LPARAM);
  72.  
  73.  
  74.  
  75. class __far CPolyline : public CWindow
  76.     {
  77.     friend LRESULT __export FAR PASCAL PolylineWndProc(HWND, UINT, WPARAM, LPARAM);
  78.  
  79.     private:
  80.         POLYLINEDATA   m_pl;
  81.  
  82.         class CPolylineAdviseSink FAR * m_pAdv;
  83.  
  84.     private:
  85.         void      PointScale(LPRECT, LPPOINT, BOOL);
  86.         void      Draw(HDC, BOOL, BOOL);
  87.         void      RectConvertMappings(LPRECT, BOOL);
  88.  
  89.     public:
  90.         CPolyline(HINSTANCE);
  91.         ~CPolyline(void);
  92.  
  93.         BOOL      FInit(HWND, LPRECT, DWORD, UINT, class CPolylineAdviseSink FAR *);
  94.  
  95.         void      New(void);
  96.         BOOL      Undo(void);
  97.  
  98.         //File functions
  99.         LONG      ReadFromStorage(LPSTORAGE);
  100.         LONG      WriteToStorage(LPSTORAGE, LONG);
  101.         LONG      ReadFromFile(LPSTR);
  102.         LONG      WriteToFile(LPSTR, LONG);
  103.  
  104.         //Data transfer functions
  105.         LONG      DataSet(LPPOLYLINEDATA, BOOL, BOOL);
  106.         LONG      DataGet(LPPOLYLINEDATA, LONG);
  107.         LONG      DataSetMem(HGLOBAL, BOOL, BOOL, BOOL);
  108.         LONG      DataGetMem(LONG, HGLOBAL FAR *);
  109.         HBITMAP   RenderBitmap(void);
  110.         HMETAFILE RenderMetafile(void);
  111.         HGLOBAL   RenderMetafilePict(void);
  112.  
  113.         void      RectGet(LPRECT);
  114.         void      SizeGet(LPRECT);
  115.         void      RectSet(LPRECT, BOOL);
  116.         void      SizeSet(LPRECT, BOOL);
  117.         COLORREF  ColorSet(UINT, COLORREF);
  118.         COLORREF  ColorGet(UINT);
  119.         UINT      LineStyleSet(UINT);
  120.         UINT      LineStyleGet(void);
  121.     };
  122.  
  123. typedef CPolyline FAR * LPCPolyline;
  124.  
  125.  
  126. //Error values for data transfer functions
  127. #define POLYLINE_E_NONE                    0
  128. #define POLYLINE_E_UNSUPPORTEDVERSION      -1
  129. #define POLYLINE_E_INVALIDPOINTER          -2
  130. #define POLYLINE_E_READFAILURE             -3
  131. #define POLYLINE_E_WRITEFAILURE            -4
  132.  
  133.  
  134.  
  135.  
  136. class __far CPolylineAdviseSink
  137.     {
  138.     private:
  139.         LPVOID      m_pv;                       //Customizable structure
  140.  
  141.     public:
  142.         CPolylineAdviseSink(LPVOID);
  143.         ~CPolylineAdviseSink(void);
  144.  
  145.         void OnPointChange(void);
  146.         void OnSizeChange(void);
  147.         void OnDataChange(void);
  148.         void OnColorChange(void);
  149.         void OnLineStyleChange(void);
  150.     };
  151.  
  152. typedef CPolylineAdviseSink FAR * LPCPolylineAdviseSink;
  153.  
  154.  
  155. //Color indices for color messages
  156. #define POLYLINECOLOR_BACKGROUND    0
  157. #define POLYLINECOLOR_LINE          1
  158.  
  159.  
  160.  
  161. #endif  //_POLYLINE_H_
  162.